import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import i18n from './i18n'

// 导入Element Plus
import ElementPlus from 'element-plus'
import 'element-plus/theme-chalk/dark/css-vars.css'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import App from './App.vue'
import router from './router'

const app = createApp(App)

// 1. 首先注册状态管理
const pinia = createPinia()
app.use(pinia)

// 2. 然后注册路由
app.use(router)

// 3. 注册国际化(确保响应式系统已初始化)
app.use(i18n)

// 4. 最后注册UI组件库
app.use(ElementPlus)

// 全局注册Element Plus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 确保所有插件注册完成后再挂载
app.mount('#app')
